package com.comunity_cloud.client.model;

import java.util.Hashtable;
import java.util.Map;

import org.jivesoftware.smack.XMPPException;

import com.comunity_cloud.client.model.xmpp.XMPPClient.PresenceMode;
import com.comunity_cloud.client.model.xmpp.XMPPClient;
import com.comunity_cloud.client.model.xmpp.XMPPPresenceListener;

public class PresenseModel implements XMPPPresenceListener{


	private XMPPClient xmppClient;
	
	private Map<String, PresenceMode> presenseState = new Hashtable<>();

	public PresenseModel(XMPPClient xmppClient) {
		this.xmppClient = xmppClient;
	}
	
	@Override
	public void subscribeRequest(String userName) {
		try {
			xmppClient.addFriend(userName);
		} catch (XMPPException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void presenceChanged(String userName, PresenceMode presence) {
		if(presence == PresenceMode.ONLINE) {
			MainModel2.getInstance().updateClientPorts(userName);
		}
		presenseState.put(userName, presence);
	}

	@Override
	public void entryAdded(String username) {
		
	}

	@Override
	public void entryDeleted(String usernames) {
		
	}

	@Override
	public void entryUpdated(String userName) {
		
	}

	@Override
	public void onRosterUpdated() {
		
	}
	
	

}
